package com.sky.controller.admin;

import com.sky.dto.*;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderPaymentVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminOrdersController")
@RequestMapping("/admin/order")
@Api(tags = "B端-下单接口")
@Slf4j
public class OrdersController {
    @Autowired
    private OrderService orderService;

    /**
     * 订单搜索
     *
     * @param dto
     * @return
     */
    @GetMapping("/conditionSearch")
    @ApiOperation(value = "订单搜索")
    public Result page(OrdersPageQueryDTO dto) {
        return orderService.pageAdmin(dto);
    }

    /**
     * 管理端查询订单详情
     * @param id
     * @return
     */
    @GetMapping("/details/{id}")
    @ApiOperation(value ="查询订单详情" )
    public Result details(@PathVariable Long id){
        return orderService.details(id);
    }

    /**
     * 各个状态的订单数量统计
     * @return
     */
    @GetMapping("/statistics")
    @ApiOperation(value = "各个状态的订单数量统计")
    public Result statistics(){
        return orderService.statistics();
    }
    /**
     * 取消订单
     * @param dto
     * @return
     */
    @PutMapping("/cancel")
    @ApiOperation(value = "取消订单")
    public Result cancelOrder(@RequestBody OrdersCancelDTO dto){
        return orderService.cancelOrder(dto);
    }

    /**
     * 接单
     * @param dto
     * @return
     */
    @PutMapping("/confirm")
    @ApiOperation(value = "接单")
    public Result confirm(@RequestBody OrdersConfirmDTO dto){
        return orderService.confirm(dto);
    }
    /**
     * 拒单delivery/{id}
     * @param dto
     * @return
     */
    @PutMapping("/rejection")
    @ApiOperation(value = "拒单")
    public Result rejection(@RequestBody OrdersRejectionDTO dto){
        return orderService.rejection(dto);
    }
    /**
     * 派送订单
     * @param id
     * @return
     */
    @PutMapping("/delivery/{id}")
    @ApiOperation(value = "派送订单")
    public Result delivery(@PathVariable Long id ){
        return orderService.delivery(id);
    }
    /**
     * 完成订单
     * @param id
     * @return
     */
    @PutMapping("/complete/{id}")
    @ApiOperation(value = "完成订单")
    public Result complete(@PathVariable Long id ){
        return orderService.complete(id);
    }
}
